package exe1;

public class Book implements Cloneable{

	private String name;
	private Author author;
	private double price;
	private int qty = 0;
	
	public Book(String name, Author author, double price) {
		this.name = name;
		this.author = author;
		this.price = price;
	}
	
	public Book(String name, Author author, double price, int qty) {
		this.name = name;
		this.author = author;
		this.price = price;
		this.qty = qty;
	}
	
	public double getPrice() {
		return price;
	}
	
	public void setPrice(double price) {
		this.price = price;
	}
	
	public int getQty() {
		return qty;
	}
	
	public void setQty(int qty) {
		this.qty = qty;
	}
	
	public String getName() {
		return name;
	}
	
	public Author getAuthor() {
		return author;
	}
	
	public void setAuthor(Author author) {
		this.author = author;
	}
	
	public Object clone() {
		Author author = new Author(this.author.getName(), this.author.getEamil(), this.author.getGender());
		Book book = new Book(this.name, author, this.price, this.qty);
		return book;
	}
	
	public boolean equals(Object obj) {
		if (!(obj instanceof Book)) {
			return false;
		}
		Book book = (Book)obj;
		return this.name.equals(book.getName()) &&
				this.author.getEamil().equals(book.getAuthor().getEamil());
	}
	
	public int hashCode() {
		String str = this.author.getEamil() + this.name;
		return str.hashCode();
	}
	
	public String toString() {
		return "Book[name=" + name
				+ ", " + author
				+ ", price=" + price
				+ ", qty=" + qty + "]";
	}
	
}
